int rowvalue = 6; int keyvalue =0; void setup() { // put your setup code here, to run once: pinMode (2,OUTPUT); pinMode (3,OUTPUT); pinMode (4,OUTPUT); pinMode (5,OUTPUT); pinMode (6,INPUT_PULLUP); pinMode (7,INPUT_PULLUP); pinMode (8,INPUT_PULLUP); pinMode (9,INPUT_PULLUP); pinMode (10,INPUT_PULLUP); digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: for ( int column = 2; column <6; column++) { digitalWrite(column,LOW); for ( int row =6; row <11; row ++) { if (digitalRead (row)==LOW) { keyvalue = rowvalue + column; } rowvalue = rowvalue + 4; } rowvalue = 6; digitalWrite (column, HIGH); } Serial.println(keyvalue); keyvalue = 0; rowvalue = 6; delay (100); }